﻿@using ALinq.BBS.App_GlobalResources
@using ALinq.BBS.DataAccess
@using ALinq.BBS
@{
    //ViewBag.Title = "Index";
    //ViewBag.Css = "Default.css";
    PageData["Title"] = Label.Home;
    PageData["Css"] = "Default.css";
    Layout = "_LayoutBase.cshtml";
    var boards = (IEnumerable<Board>)base.Model;
}
@foreach (var board in boards)
{
    <table cellpadding="0" cellspacing="1" class="board" style="width: 100%" id="table">
        <thead>
            <tr>
                <td colspan="5" align="left" class="boardHeader">
                    <div style="float: left;">
                        @board.Name
                    </div>
                </td>
            </tr>
            <tr>
                <td style="height: 24px; width: 75px;" class="boardTitle">
                    &nbsp;
                </td>
                <td style="height: 24px;" class="boardTitle">
                    @Label.Forums
                </td>
                <td style="height: 24px; width: 120px;" class="boardTitle">
                    @Label.Posts / @Label.Replies
                </td>
                <td style="height: 24px; width: 250px;" class="boardTitle">
                    @Label.LastPost
                </td>
                <td style="height: 24px; width: 180px;" class="boardTitle">
                    @Label.Moderators
                </td>
            </tr>
        </thead>
        <tbody>
            @foreach (var forum in board.Forums.Where(o => o.Parent == null))
            {
                var lastPost = forum.LastPost;
                var postListIndex = forum.Posts.PagesCount - 1;
                <tr class="boardItem">
                    <td valign="top" style="text-align: center;" class="icon">
                        <img alt="New" src="../../Content/Images/NewIcon.gif" />
                    </td>
                    <td align="left" class="name">
                        <div>
                            @this.CreatePostListPageLink(forum.Name, board.ID, forum.ID)
                        </div>
                        <div style="margin-top: 6px; color: #636563">
                        </div>
                    </td>
                    <td align="center" class="count">
                        @forum.Posts.Count / @forum.RepliesCount
                    </td>
                    <td align="left" valign="middle" class="last">
                        @if (lastPost != null)
                        {
                            var obj = new { boardID = board.ID, forumID = forum.ID, postListIndex, postID = lastPost.ID };
                            <div>
                                @this.CreatePostPageLink(board.ID, forum.ID, lastPost.Title, lastPost.ID)
                            </div>
                            <div>
                                @this.CreateUserPageLink(lastPost.UserName)
                            </div>
                        }
                        else
                        {

                        }
                    </td>
                    <td align="center" valign="middle" class="boarder">
                        @*<asp:Repeater ID="rptBoarders" DataSource='<%# GetBoard(Eval("Url").ToString()).Boarders %>' runat="server">
                                        <ItemTemplate>
                                            <nobr>
                                                <%#Eval("Title")%></nobr>
                                        </ItemTemplate>
                                    </asp:Repeater>*@
                    </td>
                </tr>
            }
        </tbody>
    </table>

}
